package com.other;

import java.io.*;

/**
 * Created by baiguantao on 2017/7/13.
 */
public class FileUtils {


    public static void getString(String filename) {
        BufferedReader bufferedReader = null;
        try {
            InputStream is = Thread.currentThread().getContextClassLoader().getSystemResourceAsStream(filename);
            //bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
            bufferedReader = new BufferedReader(new InputStreamReader(is));
            StringBuffer sb = new StringBuffer();
            String str = null;
            while ((str = bufferedReader.readLine()) != null) {
                sb.append(str);
            }
            System.out.println(sb.toString());

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                bufferedReader.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    public static void main(String[] args) {
        FileUtils.getString("url.txt");
    }
}
